package com.mfin.bs.mappers.impl;

import com.mfin.bom.interfaces.IAddress;
import com.mfin.vo.AddressVO;
import com.mfin.vo.interfaces.IMappable;

public class AddressMapper extends BaseMapper {
	@Override
	protected boolean doMap(IMappable fromArg, IMappable toArg) {
		boolean canPerformMap = false;

		if (fromArg instanceof IAddress && toArg instanceof AddressVO) {
			canPerformMap = true;
			performMap((IAddress) fromArg, (AddressVO) toArg);
		} else if (fromArg instanceof AddressVO && toArg instanceof IAddress) {
			performMap((AddressVO) fromArg, (IAddress) toArg);
			canPerformMap = true;
		}
		return canPerformMap;
	}

	private void performMap(AddressVO fromArg, IAddress toArg) {
		toArg.setAddressLine1(fromArg.getAddressLine1());		
		toArg.setAddressLine2(fromArg.getAddressLine2());		
		toArg.setVillage(fromArg.getVillage());		
		toArg.setCity(fromArg.getCity());		
		toArg.setDistrict(fromArg.getDistrict());		
		toArg.setState(fromArg.getState());		
		toArg.setPincode(fromArg.getPincode());
	}

	private void performMap(IAddress fromArg, AddressVO toArg) {
		toArg.setAddressLine1(fromArg.getAddressLine1());		
		toArg.setAddressLine2(fromArg.getAddressLine2());		
		toArg.setVillage(fromArg.getVillage());		
		toArg.setCity(fromArg.getCity());		
		toArg.setDistrict(fromArg.getDistrict());		
		toArg.setState(fromArg.getState());		
		toArg.setPincode(fromArg.getPincode());
	}
}
